{% extends 'base.html' %}
{% load horizon %}
{% load i18n %}
{% block main %}
    <form action="{% url "horizon:ratingfunction:billing:advanced_setting" %}" method="post">
        {% csrf_token %}
        <input type="hidden" name="total_context" value=" {{ total_context }}">
        {#        {{ total_context }}#}
        <div class="container-fluid bg">
            <div class="nav-progress">
                <span class="actived">1</span>
                <span class="active-text">基础配置</span>
                <span class="lined"></span>
                <span class="actived">2</span>
                <span class="active-text">网络设置</span>
                <span class="lined"></span>
                <span class="active">3</span>
                <span class="active-text">高级设置</span>
                <span class="line"></span>
                <span class="no-active">4</span>
                <span class="no-active-text">确认设置</span>
            </div>
            {% block service_password %}
                {% include "ratingfunction/billing/advanced_setting/_service_password.html" %}
            {% endblock %}
            {% block security_group %}
                {% include "ratingfunction/billing/advanced_setting/_security_groups.html" %}
            {% endblock %}
            {% block configuration %}
                {% include "ratingfunction/billing/advanced_setting/_configuration.html" %}
            {% endblock %}
            {% block key_pairs %}
                {% include "ratingfunction/billing/advanced_setting/_key_pairs.html" %}
            {% endblock %}
        </div>
        {% block instance_count_button %}
            {% include "ratingfunction/billing/basic_setting/_instance_count_button.html" %}
        {% endblock %}

    </form>
    <script>
        {#处理主机数量的大小#}
        var intanceCount = $("#intance_count");
        $("#instance_min").on("click", function () {
            if (parseInt(intanceCount.val()) > 1) {
                intanceCount.val(parseInt(intanceCount.val()) - 1)
            } else {
                $("#min").attr("disabled", "disabled")
            }
            setTotal();
        })
        $("#instance_max").on("click", function () {
            intanceCount.val(parseInt(intanceCount.val()) + 1);
            $("#min").removeAttr("disabled");
            setTotal();
        })

        function setTotal() {
            var intanceCount = $("#intance_count").val();
            var singleMoney = $("#single_money").val();
            var totalMoney = singleMoney * intanceCount;
            var totalMoneyResult = totalMoney.toFixed(3)//保留小数点后面3位
            $("#total_money").text("￥" + totalMoneyResult + "元/小时");
        }
    </script>

{% endblock %}